package com.inspur.edp.common.type.deserializer;

import com.fasterxml.jackson.databind.JsonNode;

/**
 * @author lizhaorui
 * @date 2025/10/30
 * @description
 */
public class BasicTypeDeserializer {

    public static class DoubleDeserializer implements TypeDeserializer {

        @Override
        public Object deserialize(JsonNode jsonNode) {
            if (jsonNode == null) {
                return (double) 0;
            }
            return jsonNode.asDouble();
        }
    }

    public static class BooleanDeserializer implements TypeDeserializer {

        @Override
        public Object deserialize(JsonNode jsonNode) {
            if (jsonNode == null) {
                return false;
            }
            return jsonNode.asBoolean();
        }
    }

    public static class IntegerDeserializer implements TypeDeserializer {

        @Override
        public Object deserialize(JsonNode jsonNode) {
            if (jsonNode == null) {
                return false;
            }
            return jsonNode.asInt();
        }

    }

    public static class LongDeserializer implements TypeDeserializer {

        @Override
        public Object deserialize(JsonNode jsonNode) {
            if (jsonNode == null) {
                return false;
            }
            return jsonNode.asLong();
        }
    }


}